import request from '@/utils/request'
// import qs from 'qs'

export function getAdminList(data) {
  return request({
    url: '/admin/list',
    method: 'post',
    data
  })
}

export function getAdmin(userId) {
  return request({
    url: '/admin/get_admin',
    method: 'post',
    params: { userId }
  })
}

export function editAdmin(data) {
  return request({
    url: '/admin/edit',
    method: 'post',
    data
  })
}

export function addAdmin(data) {
  return request({
    url: '/admin/add',
    method: 'post',
    data
  })
}

export function getFunctionList(parent) {
  return request({
    url: '/permission/list',
    method: 'post',
    // data
    params: { parent }
  })
}

export function getFunction(id) {
  return request({
    url: 'permission/permission',
    methon: 'post',
    params: { id }
  })
}

export function editFucntion(data) {
  return request({
    url: '/permission/edit',
    method: 'post',
    data
  })
}

export function addFucntion(data) {
  return request({
    url: '/permission/add',
    method: 'post',
    data
  })
}

export function editFunctionStatus(id, status) {
  return request({
    url: '/permission/edit_status',
    method: 'post',
    params: { id, status }
  })
}

export function getRoleList() {
  return request({
    url: '/role/list',
    method: 'post'
  })
}

export function getAllFucntion() {
  return request({
    url: '/role/all_permission',
    method: 'post'
  })
}

export function getRoleFunctionTree(id) {
  return request({
    url: 'role/role_permission',
    method: 'post',
    params: { id }
  })
}

export function getRoleFunction(id) {
  return request({
    url: 'role/permission',
    method: 'post',
    params: { id }
  })
}

export function setRoleFunction(roleId, permissions) {
  return request({
    url: '/role/set_permission',
    method: 'post',
    data: {
      roleId, permissions
    }
  })
}

export function addRole(roleName) {
  return request({
    url: '/role/add',
    method: 'post',
    params: { roleName }
  })
}

export function editRole(data) {
  return request({
    url: '/role/edit',
    method: 'post',
    data
  })
}

export function editRoleStatus(id, status) {
  return request({
    url: '/role/edit_status',
    method: 'post',
    params: { id, status }
  })
}

export function chgPassword(password, newPass) {
  return request({
    url: '/admin/passwd',
    method: 'post',
    params: { password, newPass }
  })
}

export function getUserList(data) {
  return request({
    url: '/admin/list',
    method: 'post',
    data
  })
}

export function addUserInfo(data) {
  return request({
    url: '/admin/add',
    method: 'post',
    data
  })
}

export function editUserInfo(data) {
  return request({
    url: '/admin/edit',
    method: 'post',
    data
  })
}

export function editUserStatus(id, status) {
  return request({
    url: '/admin/status',
    method: 'post',
    params: { id, status }
  })
}
